<h1>{:$Think.ACTION_NAME ==='edit' ? '编辑' : '新增'}维修记录</h1>

<div class="row" id="edit">
    <form method="post" action="{:U('Repair/save')}" data-ajax-save-oncompleted="onAjaxSaveCompleted"
        widget="ajax-save validation">
        <input type="hidden" value="{$data.detail_id}" name="detail_id">
        <table class="table table-input">
            <colgroup>
                <col width="1">
                <col width="100">
            </colgroup>
            <tbody>
            <tr>
                <td class="icon"><div><span class="icon-star"></span></div></td>
                <td class="key"><div>车牌号：</div></td>
                <td class="value">
                    <div>
                        <input type="text" class="form-control"
                               name="customer_car_number" 
                               value="{$data.customer_car_number}" 
                               data-required="true"
                               data-required-message="非空"
                               data-minlength="6"
                               data-minlength-message="最小长度为6"
                               data-error-container="#tipsMinlength"
                                >
                        <span class="text-muted">车牌号必须填写。填写格式：粤B:WW520</span>
                        <span class="error" id="tipsMinlength"></span>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="icon"><div></div></td>
                <td class="key"><div>客户姓名：</div></td>
                <td class="value">
                    <div>
                        <input type="hidden" value="{$data.customer_id}" name="customer_id">
                        <input type="text" class="form-control"
                               name="customer_name"
                               value="{$data.customer_name}" 
                               data-required="true"
                               data-required-message="非空"
                               data-regexp="^[\u4e00-\u9faf]+$"
                               data-regexp-message="只能输入汉字"
                               data-error-container="#tipsCn"
                                >
                        <span class="error" id="tipsCn"></span>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="icon"><div></div></td>
                <td class="key"><div>联系方式：</div></td>
                <td class="value">
                    <div>
                        <input type="text" class="form-control"
                               name="customer_phone"
                               value="{$data.customer_phone}" 
                               data-required="true"
                               data-required-message="非空"
                               data-type="digits"
                               data-type-digits-message="只能输入数字"
                               data-error-container="#tipsNumber"
                                >
                        <span class="error" id="tipsNumber"></span>
                        
                    </div>
                </td>
            </tr>
            <tr>
                <td class="icon"><div></div></td>
                <td class="key"><div>客户公司\单位：</div></td>
                <td class="value">
                    <div>
                        <input type="text" class="form-control"
                               name="customer_company"
                               value="{$data.customer_company}" 
                               data-required="true"
                               data-required-message="非空"
                               data-error-container="#tipsAlp"
                                >
                        <span class="error" id="tipsAlp"></span>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="icon"><div><span class="icon-star"></span></div></td>
                <td class="key"><div>维修项目：</div></td>
                <td class="value">
                    <div>
                        <select class="form-control"
                                name="detail_fix_type_id" 
                                data-required="true"
                                data-error-message="请选择"
                                data-error-container="#detail_fix_type_id">
                            <option value="">请选择</option>
                            <volist name="type" id="type">
                                <option value="{$key}" {:$key == $data['detail_fix_type_id'] ? 'selected' :''}>{$type}</option>
                            </volist>
                        </select>
                        <span class="error" id="detail_fix_type_id"></span>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="icon"><div><span class="icon-star"></span></div></td>
                <td class="key"><div>维修费用：</div></td>
                <td class="value">
                    <div>
                        <input type="text" class="form-control" id="password"
                               data-required="true"
                               value="{$data.detail_fix_charge}" 
                               name="detail_fix_charge" 
                               data-required-message="维修费用不能为空"
                               data-error-container="#tipsPw">
                        <span class="error" id="tipsPw"></span>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="icon"><div></div></td>
                <td class="key"><div>维修员工：</div></td>
                <td class="value">
                    <div>
                        <select class="form-control"
                                name="detail_fix_staff_id" 
                                data-required="true"
                                data-error-message="请选择"
                                data-error-container="#detail_fix_staff_id">
                            <option value="">请选择</option>
                            <volist name="staff" id="staff">
                                <option value="{$key}" {:$key == $data['detail_fix_staff_id'] ? 'selected' :''}>{$staff}</option>
                            </volist>
                        </select>
                        <span class="error" id="detail_fix_staff_id"></span>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="icon"></td>
                <td class="key"><div>维修时间：</div></td>
                <td class="value">
                    <div>
                        <input type="text" name="detail_fix_time" value="{$data.detail_fix_time}" class="form-control" style="width: 200px;" widget="datepicker" readonly>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="icon"></td>
                <td class="key"><div>维修配件：</div></td>
                <td class="value">
                    <div>
                        <select class="form-control"
                                name="detail_fix_parts_id"
                                data-required="true"
                                data-error-message="请选择"
                                data-error-container="#detail_fix_parts_id">
                            <option value="{$data.detail_car_number}">请选择</option>
                            <volist name="parts" id="parts">
                                <option value="{$key}" {:$key == $data['detail_fix_parts_id'] ? 'selected' :''}>{$parts}</option>
                            </volist>
                        </select>
                        <span class="error" id="detail_fix_parts_id"></span>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="icon"></td>
                <td class="key"><div>维修备注：</div></td>
                <td class="value">
                    <div>
                        <textarea name="detail_fix_describe" class="form-control" style="width:200px;height:100px;">{$data.detail_fix_describe}</textarea>
                    </div>
                </td>
            </tr>
            
            </tbody>
        </table>
        <div class="op">
            <input type="submit" class="btn btn-default" value="保存">
            <a class="btn btn-warning" href="">取消</a>
        </div>
    </form>
</div>
<script>
    function onAjaxSaveCompleted(obj) {
        if (obj.json.error) {
            util.modal({
                body: obj.json.message
            });
        } else {
            window.location.href = obj.json.data;
        }
        return false;
    }
</script>